import {
  Controller,
  Get,
  Post,
  Body,
  Patch,
  Param,
  Delete,
  Req,
  Query,
} from '@nestjs/common';
import { CartService } from './cart.service';
import { CreateCartDto } from './dto/create-cart.dto';
import { UpdateCartDto } from './dto/update-cart.dto';
// import { ApiProperty, ApiQuery } from '@nestjs/swagger';

@Controller('cart_admin')
export class CartController {
  constructor(private readonly cartService: CartService) {}

  @Post()
  create(@Body() createCartDto: CreateCartDto) {
    return this.cartService.create(createCartDto);
  }

  // @Get('get_cart')
  // @ApiProperty({ description: '分页获取用户的购物车情况' })
  // @ApiQuery({ name: 'pageSize', description: '数据条数', required: true })
  // @ApiQuery({ name: 'currentPage', description: '当前页码', required: true })
  // findCart(
  //   @Req() req,
  //   @Query('currentPage') currentPage,
  //   @Query('pageSize') pageSize,
  // ) {
  //   return this.cartService.findAllCartByUserId(
  //     +req.managerInfo.sub,
  //     +currentPage,
  //     +pageSize,
  //   );
  // }

  @Get()
  findAll() {
    return this.cartService.findAll();
  }

  @Get(':id')
  findOne(@Param('id') id: string) {
    return this.cartService.findOne(+id);
  }

  @Patch(':id')
  update(@Param('id') id: string, @Body() updateCartDto: UpdateCartDto) {
    return this.cartService.update(+id, updateCartDto);
  }

  @Delete(':id')
  remove(@Param('id') id: string) {
    return this.cartService.remove(+id);
  }
}
